package com.catchu.pattern.creational.适配器模式.基于对象;

/**
 * 用户注册类
 */
public class UserRegister {

    private UserManageInterface userManage;

    public UserRegister(UserManageInterface userManage) {
        this.userManage = userManage;
    }

    /**
     * 用户注册
     * @param userName 用户注册
     * @param orgCode 机构代码
     */
    public void userRegister(String userName,String orgCode){
        try {
            Integer userId = userManage.addUser(userName);
            addUser2Org(userId,orgCode);
        } catch (Exception e) {
            System.out.println("用户\""+userName+"\"注册失败："+e.getMessage()+";");
        }
    }

    public void addUser2Org(Integer userId,String orgCode){
        System.out.println("ID为\""+userId+"\"的用户被添加到组织\""+orgCode+"\"中;");
    }
}
